package com.guochenglang.www.dao.impl;

import com.guochenglang.www.dao.CommentDao;
import com.guochenglang.www.pojo.Comment;
import com.guochenglang.www.util.GetTable;
import com.guochenglang.www.util.connect.JdbcUtil;

import java.sql.SQLException;
import java.util.ArrayList;

/**
 * 评论表的的Dao层
 *
 * @author 郭程朗
 */
public class CommentDaoImpl implements CommentDao {
    /**
     * 表名
     */
    private static final String TABLE = GetTable.getTable(Comment.class);

    public CommentDaoImpl() {
    }

    @Override
    public ArrayList<Comment> commentSelect(Comment comment) throws SQLException, IllegalAccessException, InstantiationException, InterruptedException {
        return JdbcUtil.selectMax(TABLE, comment);
    }

    @Override
    public ArrayList<Comment> commentSelectByLimit(int page, int num, Comment comment, String order, String mode) throws SQLException, InterruptedException, IllegalAccessException, InstantiationException {
        return JdbcUtil.selectByLimit(TABLE, page, num, comment, order, mode);
    }


    @Override
    public int insertComment(Comment comment) throws SQLException, InterruptedException, IllegalAccessException {
        return JdbcUtil.insert(TABLE, comment);
    }

    @Override
    public int updateComment(Comment set, Comment conditions) throws SQLException, InterruptedException, IllegalAccessException {
        return JdbcUtil.update(TABLE, set, conditions);
    }

    @Override
    public int deleteComment(Comment conditions) throws SQLException, InterruptedException, IllegalAccessException {
        return JdbcUtil.delete(TABLE, conditions);
    }
}
